<template>
  <div id="dialogLifeUp">
    <el-dialog
      title="修改批量点赞数量"
      :visible.sync="dialogData.isShow"
      width="420px"
      :before-close="labelHandleClose"
    >
      <div class="form-box">
        <el-form
          ref="ruleForm"
          :model="ruleForm"
          :rules="rules"
          label-width="80px"
          class="demo-ruleForm"
          @submit.native.prevent
        >
          <el-form-item label="点赞量" prop="num">
            <el-input-number
              v-model="ruleForm.num"
              size="mini"
              controls-position="right"
              :min="1"
            ></el-input-number>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="success" plain @click="cancelLabel">取 消</el-button>
        <el-button type="success" :loading="loading" @click="confirmLabel"
          >确认</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'dialogLifeUp',
  msg: '批量加赞',
  props: ['dialogData'],
  data() {
    return {
      loading: false,
      ruleForm: {
        num: 1
      },
      rules: {
        num: [
          { required: true, message: '点赞量不能为空' }
          /* {min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur'} */
        ]
      }
    }
  },
  mounted() {},
  methods: {
    labelHandleClose(done) {
      this.cancelLabel()
      done()
    },
    cancelLabel() {
      // 关闭前清空
      this.loading = false
      this.dialogData.isShow = false
    },
    /* 确认提交 */
    confirmLabel() {
      this.loading = true
      this.$emit('addUp', this.ruleForm.num, 'batch') // 批量加赞类型为"batch"
      this.cancelLabel()
    }
  }
}
</script>

<style lang="less">
#dialogLifeUp {
  .el-input-number--mini {
    width: 220px;
  }
}
</style>
